Telegram Group & Telegram Channel
Гарантирует ли ConcurrentHashMap видимость между потоками? Нужно ли дополнительно синхронизировать put() и get() для корректной работы?

ConcurrentHashMap уже обеспечивает необходимую памятную видимость (happens-before) между put() и get() — дополнительная синхронизация не нужна.

Если put() завершился до начала get(), то get() обязательно увидит вставленное значение. Это гарантируется внутренней реализацией: через volatile поля, CAS-операции и memory barriers.

🐸 Библиотека собеса по Java
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/java_interview_lib/860
Create:
Last Update:

Гарантирует ли ConcurrentHashMap видимость между потоками? Нужно ли дополнительно синхронизировать put() и get() для корректной работы?

ConcurrentHashMap уже обеспечивает необходимую памятную видимость (happens-before) между put() и get() — дополнительная синхронизация не нужна.

Если put() завершился до начала get(), то get() обязательно увидит вставленное значение. Это гарантируется внутренней реализацией: через volatile поля, CAS-операции и memory barriers.

🐸 Библиотека собеса по Java

BY Библиотека собеса по Java | вопросы с собеседований


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/java_interview_lib/860

View MORE
Open in Telegram


Библиотека собеса по Java | вопросы с собеседований Telegram | DID YOU KNOW?

Date: |

Telegram today rolling out an update which brings with it several new features.The update also adds interactive emoji. When you send one of the select animated emoji in chat, you can now tap on it to initiate a full screen animation. The update also adds interactive emoji. When you send one of the select animated emoji in chat, you can now tap on it to initiate a full screen animation. This is then visible to you or anyone else who's also present in chat at the moment. The animations are also accompanied by vibrations. This is then visible to you or anyone else who's also present in chat at the moment. The animations are also accompanied by vibrations.

The S&P 500 slumped 1.8% on Monday and Tuesday, thanks to China Evergrande, the Chinese property company that looks like it is ready to default on its more-than $300 billion in debt. Cries of the next Lehman Brothers—or maybe the next Silverado?—echoed through the canyons of Wall Street as investors prepared for the worst.

Библиотека собеса по Java | вопросы с собеседований from de


Telegram Библиотека собеса по Java | вопросы с собеседований
FROM USA